package com.sunrate.investingquote.service.router.comparator.test.compare.v1;

import com.sunrate.investingquote.bean.router.ChannelRouter;
import com.sunrate.investingquote.dto.router.comparator.RouterSortContext;

import java.util.Comparator;

/**
 * @author yyh
 * @description:
 * @date 2023/07/04/ 15:12
 */
public class DefaultComparator extends ComparatorCreator {

    private static final String CODE = "default";

    @Override
    protected Comparator<RouterSortContext<ChannelRouter>> create(ChainParam chainParam) {
        return Comparator.comparing(RouterSortContext::getDefaultPriority, Comparator.nullsLast(Integer::compareTo).reversed());
    }

    @Override
    protected String getCode() {
        return CODE;
    }

    @Override
    protected void setOrder(ChainParam chainParam) {
        this.order = Integer.MIN_VALUE;
    }

    @Override
    protected boolean support(ChainParam chainParam) {
        return true;
    }
}
